package controller;

import entity.Category;
import entity.MyResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import service.CategoryService;

import java.util.List;

@RestController//相当于@Controller+@Restbody
@RequestMapping("/category")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    @GetMapping("/childCategory")
    public MyResult<List<Category>> findChildCategory(Integer parentid){
       List<Category> categories=categoryService.selectByParentId(parentid);
       return new MyResult<>(200,"查询成功",categories);
    }
}
